<?
/*********************************************
*新闻列表
* *******************************************/
function smarty_function_qishi_news_list($params, &$smarty)
{ 
extract($params);
global $db,$_CFG;
$paged = (NULL != $paged) ? $paged : 0; //是否分页显示
$row = (NULL != $row) ? $row : 15; //默认显示记录数量
$start = (NULL != $start) ? $start : 0; //记录起始位置
$titlelen = (NULL != $titlelen) ? $titlelen : 15; //默认标题长度
$infolen = (NULL != $infolen) ? $infolen : 35; //表示内容简介长度
$dot = (NULL != $dot) ? $dot : ''; //默认截取后填补字符
$listname = (NULL != $listname) ? $listname : "list"; //默认的section名称
$settr = (NULL != $settr) ? $settr : ""; //时间范围
$wheresql=" WHERE is_display='1' ";
$classify?$wheresql.=" AND ParentID='".intval($classify)."' ":'';//新闻分类ID
$typeid?$wheresql.=" AND type_id='".intval($typeid)."' ":'';//新闻栏目ID
$attribute?$wheresql.=" AND focos='".intval($attribute)."' ":'';//文章属性
$img?$wheresql.=" AND Small_img<>'' ":'';//是否为图片新闻
if (intval($settr))
{
$settr_val=strtotime("-".$settr." day");
$wheresql.=" AND addtime > ".$settr_val;
}
//排列字段
$orderby=ereg('article_order|click|addtime|id',$orderby)?$orderby:"article_order";
//显示顺序
$displayorder=ereg('asc|desc',$displayorder)?$displayorder:"DESC";
//sql语句
if ($orderby=="id") $orderbysql=" ORDER BY ".$orderby." ".$displayorder;
if ($orderby<>"id") $orderbysql=" ORDER BY ".$orderby." ".$displayorder.",id DESC";
if ($paged=="1")
{
require_once(QISHI_ROOT_PATH.'include/page.class.php');
$total_sql="SELECT COUNT(*) AS num FROM ".table('article').$wheresql;
$total_count=get_total($total_sql);
$page = new page(array('total'=>$total_count, 'perpage'=>$row,'action'=>'news_page','id0'=>$typeid));
$currenpage=$page->nowindex;
$start=($currenpage-1)*$row;
if ($total_count>$row)
{
$smarty->assign('page',$page->show(3));//分页符
}
}
if(!empty($row))
{
$start=$start?$start:0;
$limit=" LIMIT ".$start.','.$row;
}
$result = $db->query("SELECT * FROM ".table('article')." ".$wheresql.$orderbysql.$limit);
while($row = $db->fetch_array($result))
{
$style_color=$row['tit_color']?"color:".$row['tit_color'].";":'';
$style_font=$row['tit_b']=="1"?"font-weight:bold;":'';
$row['title']=cut_str($row['title'],$titlelen,0,$dot);
if ($style_color || $style_font)$row['title']="<span style=".$style_color.$style_font.">".$row['title']."</span>";
$row['url'] =$row['is_url']<>"http://"?$row['is_url']:url_rewrite('news-show',array('id0'=>$row['id']));
$row['briefly']=cut_str(html2text($row['content']),$infolen,0,$dot);
$row['img']=$_CFG['thumb_dir'].$row['Small_img'];
$List[] = $row;
}
$smarty->assign($listname, $List);
unset($List);
}
?>